﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BuyRitmus.Negocio.BLL;
using BuyRitmus.Negocio.Model;

namespace BuyRitmus.Web
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            EventoBLL eventoBLL = new EventoBLL();
            IList<EventoDTO> eventos = eventoBLL.Listar("DF");

            this.ListaEventos.DataSource = eventos;
            this.ListaEventos.DataBind();
        }

        public string FormatarDataEvento(DateTime data)
        {
            DateTimeFormatInfo dfti = new CultureInfo("pt-BR", false).DateTimeFormat;
            data = Convert.ToDateTime(data, dfti);

            string dataFinal = data.Day.ToString() + " de " + FormatarPrimeiraMaiuscula(data.ToString("MMMM").Substring(0, 3)) + ", " + FormatarPrimeiraMaiuscula(dfti.GetDayName(data.DayOfWeek).Split('-')[0]) + ", " + data.ToString("HH:mm") + " hrs.";
            return dataFinal;
        }

        private string FormatarPrimeiraMaiuscula(string s)
        {
            if (string.IsNullOrEmpty(s))
                return string.Empty;
            return char.ToUpper(s[0]) + s.Substring(1).ToLower();
        }
    }
}